package com.weixing.mall.provider.model.excel;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.weixing.mall.base.constant.DatePattern;
import com.weixing.mall.base.constant.GlobalConstant;
import com.weixing.mall.core.enums.OrderSysTagEnum;
import com.weixing.mall.base.enums.WhetherEnum;
import com.weixing.mall.provider.api.model.enums.OrderTypeEnum;
import com.weixing.mall.provider.model.enums.OrderFromEnum;
import com.weixing.mall.provider.model.enums.OrderStateEnum;
import lombok.Data;

import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 * @Author 0202
 * @Date 2020-8-21
 * @Version 1.0
 */
@Data
@ContentRowHeight(100)
public class KefuAuditOrderAllED {

    /*序号二期新增序号属性*/
    @ExcelProperty("序号")
    private String xu;
    @ExcelProperty("图片")
    private URL img;
    @ExcelProperty("订单编号")
    private String orderSn;


    /*序号二期新增分类属性*/
    @ExcelProperty("分类")
    private String classType;
    /*序号二期新增系列属性*/
    @ExcelProperty("系列")
    private String xltType;
    @ExcelProperty("商品名称")
    private String goodsName;
    @ExcelProperty("图片")
    @ExcelIgnore
    private String productImg;

    @ExcelProperty("货号")
    private String goodsSn;
    @ExcelProperty("款号")
    private String styleNo;
    @ExcelProperty("颜色/尺码")
    @ExcelIgnore
    private String productSkuDesp;
    @ExcelProperty("颜色")
    private String color;
    @ExcelProperty("尺码")
    private String size;

    @ExcelProperty("订单价格")
    private BigDecimal orderPrice;
    @ExcelProperty("下单人")
    private String buyer;
    @ExcelProperty("收货人")
    private String contactUser;
    @ExcelProperty("收货人手机号")
    private String contactPhone;
    /*序号二期新增身高属性*/
    @ExcelProperty("身高")
    private String height;
    /*序号二期新增体重属性*/
    @ExcelProperty("体重")
    private String weight;
    @ExcelProperty("收货人地址")
    private String addrDetails;
    /*序号二期新增客服备注属性*/
    @ExcelProperty("客服备注")
    private String customerRemark;
    @ExcelProperty("快递方式")
    private String expressName;
    @ExcelProperty("订单流水号")
    private String outTradeNo;
    /*序号二期新增仓库编码属性*/
    @ExcelProperty("仓库编码")
    private String depotSn;
    @ExcelProperty("所属发货员")
    private String shipperName;
    /*序号二期新增仓库编码属性*/
    @ExcelProperty("订单备注")
    private String remark;
    @ExcelProperty("下单时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date createdTime;

    @ExcelProperty("是否支付")
    private String isPayStr;
    @ExcelProperty("是否支付")
    @ExcelIgnore
    private WhetherEnum isPay;

    @ExcelProperty("下单类型")
    private String orderTypeStr;
    @ExcelProperty("下单类型")
    @ExcelIgnore
    private OrderTypeEnum orderType;

    @ExcelProperty("订单状态")
    @ExcelIgnore
    private OrderStateEnum orderStatus;
    @ExcelProperty("订单状态")
    private String orderStatusStr;

    @ExcelProperty("活动名称")
    private String actName;
    @ExcelProperty("所属客服")
    private String customerName;

    @ExcelProperty("是否线上")
    private String isOnlineStr;
    @ExcelProperty("是否线上")
    @ExcelIgnore
    private WhetherEnum isOnline;

    @ExcelProperty("订单来源")
    private String orderFromStr;
    @ExcelProperty("订单来源")
    @ExcelIgnore
    private OrderFromEnum orderFrom;

    @ExcelProperty("待审核人")
    private String unAuditor;
    @ExcelProperty("已审核人")
    private String auditedName;
    @ExcelProperty("审核时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date auditTime;
    @ExcelProperty("所属代理商")
    private String agentName;



    @ExcelProperty("发货时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date shipTime;

    @ExcelProperty("系统标签")
    private String sysTagStr;
    @ExcelProperty("系统标签")
    @ExcelIgnore
    private OrderSysTagEnum sysTag;

    @ExcelProperty("是否换货")
    @ExcelIgnore
    private Integer afterSaleTag;
    @ExcelProperty("是否换货")
    private String afterSaleTagStr;





    public void setProductImg(String productImg) {
        this.productImg = productImg;
        try {
            if (StrUtil.isNotEmpty(productImg)) {
                this.img = new URL(GlobalConstant.IMG_PATH_URL + productImg + GlobalConstant.IMG_PATH_URL_SUFFIX);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    public void setSysTag(OrderSysTagEnum sysTag) {
        this.sysTag = sysTag;
        if (sysTag != null) {
            this.sysTagStr = sysTag.getDesp();
        }
    }

    public void setIsPay(WhetherEnum isPay) {
        this.isPay = isPay;
        if (isPay != null) {
            this.isPayStr = isPay.getDesp();
        }
    }

    public void setOrderType(OrderTypeEnum orderType) {
        this.orderType = orderType;
        if (orderType != null) {
            this.orderTypeStr = orderType.getDesp();
        }
    }

    public void setOrderStatus(OrderStateEnum orderStatus) {
        this.orderStatus = orderStatus;
        if (orderStatus != null) {
            this.orderStatusStr = orderStatus.getDesp();
        }
    }

    public void setIsOnline(WhetherEnum isOnline) {
        this.isOnline = isOnline;
        if (isOnline != null) {
            this.isOnlineStr = isOnline.getDesp();
        }
    }

    public void setOrderFrom(OrderFromEnum orderFrom) {
        this.orderFrom = orderFrom;
        if (orderFrom != null) {
            this.orderFromStr = orderFrom.getDesp();
        }
    }

    public void setAfterSaleTag(Integer afterSaleTag) {
        this.afterSaleTag = afterSaleTag;
        if (afterSaleTag != null && afterSaleTag == 1) {
            this.afterSaleTagStr = "是";
        } else {
            this.afterSaleTagStr = "否";
        }
    }
}
